package com.example.online_order.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString

public class Result {

    private Integer status;//前端请求返回的状态码200 2**表示成功，300 3**表示资源你重定向，400 4**表示资源没找到，500 5**表示系统错误
    private String message;
    private Object data;//可以表示任何类型，主要用来表达数据
    private String token; //token 令牌

    public Result(Object data){
        this.data = data;;
        this.status = 200;
        this.message = "success";
        this.token =null;
    }


    public Result(Object data, String message){
        this.data = data;;
        this.status = 200;
        this.message = message;
        this.token = null;
    }

    public  static  Result fail(String message, Integer status) {

        return new Result(status, message, null,null);
    }

    public  static Result success(Object data){
        return new Result(data, "success");
    }

    public  static Result Login(Object data, String token){
        return new Result(200, "success",data,token);
    }


}
